package com.ruoyi.aslife.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aslife.domain.Article;
import com.ruoyi.aslife.service.IAS_ArticleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/api")
public class ArticleController2 extends BaseController{
    @Autowired
    private IAS_ArticleService aS_ArticleService;

    /**
     * 查询文章信息管理列表
     */
    @GetMapping("/article/list")
    public TableDataInfo getArticleList(Article aS_Article)
    {
        startPage();
        Article article = new Article();
        List<Article> list = aS_ArticleService.selectAS_ArticleList(article);
        return getDataTable(list);
    }

    /**
     * 查询文章信息管理列表(查询点赞数前五)
     */
    @GetMapping("/hotArticle/list")
    public TableDataInfo getArticleHotList(Article aS_Article)
    {
        Article article = new Article();
        List<Article> list = aS_ArticleService.selectAS_ArticleHotList(article);
        return getDataTable(list);
    }

    /**
     * 获取文章信息管理详细信息(根据文章ID获取文章)
     */
    @GetMapping(value = "/article/{aid}")
    public AjaxResult getArticleByAid(@PathVariable("aid") Long aid)
    {
        return success(aS_ArticleService.selectAS_ArticleByAid(aid));
    }

    /**
     * 获取文章信息管理详细信息（根据用户ID获取文章）
     */
    @GetMapping(value = "/article1/{uid}")
    public TableDataInfo getArticleListByUid(@PathVariable("uid") Long uid)
    {
        startPage();
        List<Article> list = aS_ArticleService.selectAS_ArticleByUid(uid);
        return getDataTable(list);
    }


}
